﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Forest.Lion.Data;
using Forest.Lion.Domain.Models;
using System.Collections.ObjectModel;
using Forest.Lion.Model;

namespace Forest.Lion.Domain.Handlers {
    public class ContractAppService {
        private readonly IContractRepository _contractRepository;

        public ContractAppService(IContractRepository contractRepository) {
            _contractRepository = contractRepository;
        }

        public IEnumerable<Contract> GetContractsForCompany(Guid companyId) {
            var contracts = _contractRepository
                .GetContracts(companyId)
                .Where(c=>c.Deleted == false)
                .OrderByDescending(c => c.EndDate)
                .ToList();

            return new ReadOnlyCollection<Contract>(contracts);

        }
    }
}
